import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router);

export default new Router({
  routes: [
    {

      path: '*',
      redirect: '/welcome'
    },
    {
      name: '首页',
      path: '/welcome',
      component: require('views/Welcome')
    },
    {
      name: '练习1',
      path: '/exercise/1',
      component: require('views/Exercise1')
    },
    {
      name: '练习2',
      path: '/exercise/2',
      component: require('views/Exercise2')
    },
    {
      name: '课程',
      path: '/lesson',
      component: require('views/Lesson')
    }
  ]
})

function generateRoutesFromMenu(menu = [], routes = []) {
  for (let i = 0, l = menu.length; i < l; i++) {
    let item = menu[i];
    if (item.path) {
      routes.push(item)
    }
    if (!item.component) {
      generateRoutesFromMenu(item.children, routes)
    }
  }
  return routes
}
